package com.wqb.until;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.struts2.ServletActionContext;


/**
 * @author wqb
 * @version CreateTime：Jun 1, 2012 11:07:29 AM
 * 日志帮助类
 */
public class LogUtils {
	
//	protected final Log fileLogger = org.apache.commons.logging.LogFactory.getLog("airsALog");
	
	public String sysLogForDB(){
		return "";
	}
	public void sysLogForFile(String info){
		
	}	
	
	
	/**
	 * 获取客户端IP
	 * @param request
	 * @return
	 */
	public static String getRemoteIp() {
		HttpServletRequest request = ServletActionContext.getRequest();
		String ip ="";
		if(request!=null){
			ip = request.getHeader("x-forwarded-for");
			if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
				ip = request.getHeader("Proxy-Client-IP");
			}
			if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
				ip = request.getHeader("WL-Proxy-Client-IP");
			}
			if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
				ip = request.getRemoteAddr();
			}
		}
		return ip;
	}
}
